// pages/perfection/perfection.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    info:[],
    evaluate:0,
    report:0,
    medicine:0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var docid = options.id;
    that.setData({
      docid: docid
    });
    wx.request({
      url: app.d.ceshiUrl + '/Api/Doctor/details',
      method: "post",
      data: {
        docid: docid,
      },
      header: {
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        console.log(res)
        if (res.data.status == 1) {
          that.setData({
            info: res.data.info
          });
        } else {
          wx.showToast({
            title: res.data.err,
          })
        }
      },
      fail: function (e) {
        wx.showToast({
          title: '网络异常！',
          duration: 30000
        });
      },
    })
  },
  next:function () {
    if(this.data.evaluate == 0){
      wx.showToast({
        title: '请先完成疾病评估！',
      });
      return false;
    }else if(this.data.medicine == 0){
      wx.showToast({
        title: '请先完成用药记录！',
      });
      return false;
    } else if (this.data.report == 0) {
      wx.showToast({
        title: '请先完成检验报告！',
      });
      return false;
    }
    wx.navigateTo({
      url:'../counseling/counseling?docid='+this.data.docid
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;
    wx.request({
      url: app.d.ceshiUrl + '/Api/User/check_user',
      method: "post",
      data: {
        uid: app.d.userId,
      },
      header: {
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        console.log(res)
        if (res.data.status == 1) {
          that.setData({
            evaluate: res.data.evaluate,
            report: res.data.report,
            medicine: res.data.medicine
          });
        } else {
          wx.showToast({
            title: res.data.err,
          })
        }
      },
      fail: function (e) {
        wx.showToast({
          title: '网络异常！',
          duration: 30000
        });
      },
    })
  },
  goMedicine: function () {
    wx.redirectTo({
      url:"../medication/medication"
    })
  },
  goAssessment: function () {
    wx.redirectTo({
      url:"../assessment/assessment"
    })
  },
  goReport: function () {
    wx.redirectTo({
      url:"../survey/survey"
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})